import React from 'react';
import { connect } from 'dva'
import queryString from 'query-string'
import {
  Button,
  Card,
  Modal
} from 'antd'
import AddCouponForm from './AddCouponForm';


const coupons = ({ location, dispatch, coupon, loading }) => {

  location.query = queryString.parse(location.search);

  const { items, pagination, visible ,currentSelect} = coupon;

  const setVisible = (option) => {
    if(!option){
      dispatch({
        type:'coupon/distributorQuery',
        payload:{}
      })
    }
    dispatch({
      type: 'coupon/setVisible',
      payload: option
    })
  }
  const addProps = {
    dispatch,
    setVisible: setVisible,
    currentSelect:currentSelect,
    visible,items, pagination,location,loading
  }

  return (
    <div>
      <AddCouponForm {...addProps} />
    </div>
  )
};

export default connect(({ coupon, app, loading }) => ({ coupon, app, loading }))(coupons)
